<?php

namespace app\beautiful\model\appointment;

use app\beautiful\model\StaffModel;
use app\common\model\CommonModel;



class TechnicianModel extends CommonModel{

    protected  $name = 'beautiful_technician';

    protected  $pk   = 'technician_id';

    protected $type=[

        'tags'=>'array'

    ];



    public function projects()

    {

        return $this->hasMany(TechnicianProjectModel::class,'technician_id','technician_id');

    }



    public function getTagsStringAttr($value,$data)

    {

        $tags=json_decode($data['tags'],true);

        if(empty($tags)) return '';

        return implode(',',$tags) ?? '';

    }



    public function getStatusMeansAttr($value,$data)

    {

        $status_means=[

            1=>'在职',

            -1=>'离职',

        ];

        return $status_means[$data['status']] ?? '';

    }



    public function schedulings()

    {

        return $this->hasMany(TechnicianSchedulingModel::class,'technician_id','technician_id');

    }
    public function staff()

    {

        return $this->hasOne(StaffModel::class,'staff_id','staff_id');

    }
}

